namespace Spine
{
	public class SkinnedMeshAttachment : Attachment
	{
		internal int[] bones;

		internal float[] weights;

		internal float[] uvs;

		internal float[] regionUVs;

		internal int[] triangles;

		internal float regionOffsetX;

		internal float regionOffsetY;

		internal float regionWidth;

		internal float regionHeight;

		internal float regionOriginalWidth;

		internal float regionOriginalHeight;

		internal float r = 1f;

		internal float g = 1f;

		internal float b = 1f;

		internal float a = 1f;

		public int HullLength
		{
			get;
			set;
		}

		public int[] Bones
		{
			get
			{
				return bones;
			}
			set
			{
				bones = value;
			}
		}

		public float[] Weights
		{
			get
			{
				return weights;
			}
			set
			{
				weights = value;
			}
		}

		public float[] RegionUVs
		{
			get
			{
				return regionUVs;
			}
			set
			{
				regionUVs = value;
			}
		}

		public float[] UVs
		{
			get
			{
				return uvs;
			}
			set
			{
				uvs = value;
			}
		}

		public int[] Triangles
		{
			get
			{
				return triangles;
			}
			set
			{
				triangles = value;
			}
		}

		public float R
		{
			get
			{
				return r;
			}
			set
			{
				r = value;
			}
		}

		public float G
		{
			get
			{
				return g;
			}
			set
			{
				g = value;
			}
		}

		public float B
		{
			get
			{
				return b;
			}
			set
			{
				b = value;
			}
		}

		public float A
		{
			get
			{
				return a;
			}
			set
			{
				a = value;
			}
		}

		public string Path
		{
			get;
			set;
		}

		public object RendererObject
		{
			get;
			set;
		}

		public float RegionU
		{
			get;
			set;
		}

		public float RegionV
		{
			get;
			set;
		}

		public float RegionU2
		{
			get;
			set;
		}

		public float RegionV2
		{
			get;
			set;
		}

		public bool RegionRotate
		{
			get;
			set;
		}

		public float RegionOffsetX
		{
			get
			{
				return regionOffsetX;
			}
			set
			{
				regionOffsetX = value;
			}
		}

		public float RegionOffsetY
		{
			get
			{
				return regionOffsetY;
			}
			set
			{
				regionOffsetY = value;
			}
		}

		public float RegionWidth
		{
			get
			{
				return regionWidth;
			}
			set
			{
				regionWidth = value;
			}
		}

		public float RegionHeight
		{
			get
			{
				return regionHeight;
			}
			set
			{
				regionHeight = value;
			}
		}

		public float RegionOriginalWidth
		{
			get
			{
				return regionOriginalWidth;
			}
			set
			{
				regionOriginalWidth = value;
			}
		}

		public float RegionOriginalHeight
		{
			get
			{
				return regionOriginalHeight;
			}
			set
			{
				regionOriginalHeight = value;
			}
		}

		public int[] Edges
		{
			get;
			set;
		}

		public float Width
		{
			get;
			set;
		}

		public float Height
		{
			get;
			set;
		}

		public SkinnedMeshAttachment(string name)
			: base(name)
		{
		}

		public void UpdateUVs()
		{
			float regionU = RegionU;
			float regionV = RegionV;
			float num = RegionU2 - RegionU;
			float num2 = RegionV2 - RegionV;
			float[] array = regionUVs;
			if (uvs == null || uvs.Length != array.Length)
			{
				uvs = new float[array.Length];
			}
			float[] array2 = uvs;
			if (RegionRotate)
			{
				int i = 0;
				for (int num3 = array2.Length; i < num3; i += 2)
				{
					array2[i] = regionU + array[i + 1] * num;
					array2[i + 1] = regionV + num2 - array[i] * num2;
				}
			}
			else
			{
				int j = 0;
				for (int num4 = array2.Length; j < num4; j += 2)
				{
					array2[j] = regionU + array[j] * num;
					array2[j + 1] = regionV + array[j + 1] * num2;
				}
			}
		}

		public void ComputeWorldVertices(Slot slot, float[] worldVertices)
		{
			Skeleton skeleton = slot.bone.skeleton;
			ExposedList<Bone> exposedList = skeleton.bones;
			float x = skeleton.x;
			float y = skeleton.y;
			float[] array = weights;
			int[] array2 = bones;
			if (slot.attachmentVerticesCount == 0)
			{
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				int num4 = array2.Length;
				while (num2 < num4)
				{
					float num5 = 0f;
					float num6 = 0f;
					int num8 = array2[num2++] + num2;
					while (num2 < num8)
					{
						Bone bone = exposedList.Items[array2[num2]];
						float num9 = array[num3];
						float num10 = array[num3 + 1];
						float num11 = array[num3 + 2];
						num5 += (num9 * bone.m00 + num10 * bone.m01 + bone.worldX) * num11;
						num6 += (num9 * bone.m10 + num10 * bone.m11 + bone.worldY) * num11;
						num2++;
						num3 += 3;
					}
					worldVertices[num] = num5 + x;
					worldVertices[num + 1] = num6 + y;
					num += 2;
				}
				return;
			}
			float[] attachmentVertices = slot.AttachmentVertices;
			int num12 = 0;
			int num13 = 0;
			int num14 = 0;
			int num15 = 0;
			int num16 = array2.Length;
			while (num13 < num16)
			{
				float num17 = 0f;
				float num18 = 0f;
				int num20 = array2[num13++] + num13;
				while (num13 < num20)
				{
					Bone bone2 = exposedList.Items[array2[num13]];
					float num21 = array[num14] + attachmentVertices[num15];
					float num22 = array[num14 + 1] + attachmentVertices[num15 + 1];
					float num23 = array[num14 + 2];
					num17 += (num21 * bone2.m00 + num22 * bone2.m01 + bone2.worldX) * num23;
					num18 += (num21 * bone2.m10 + num22 * bone2.m11 + bone2.worldY) * num23;
					num13++;
					num14 += 3;
					num15 += 2;
				}
				worldVertices[num12] = num17 + x;
				worldVertices[num12 + 1] = num18 + y;
				num12 += 2;
			}
		}
	}
}
